package com.hd.sup.modules.vehicle.service.impl;

import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hd.common.constant.BizConstant;
import com.hd.common.utils.DateUtil;
import com.hd.sup.modules.vehicle.mapper.VehicleTrailMapper;
import com.hd.sup.modules.vehicle.model.VehicleTrail;
import com.hd.sup.modules.vehicle.service.IVehicleTrailService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 车辆轨迹表 按天分表 服务实现类
 * </p>
 *
 * @author chentl123
 * @since 2020-12-28
 */
@Service
public class VehicleTrailServiceImpl extends ServiceImpl<VehicleTrailMapper, VehicleTrail> implements IVehicleTrailService {

    @Override
    public List<Map<String, Object>> getVehicleTrack(VehicleTrail param) {
        return this.baseMapper.getVehicleTrack(param);
    }

    @Override
    public List<Map<String, Object>> getVehicleTrackPage(Page<Map<String, Object>> page, VehicleTrail param) {
        return this.baseMapper.getVehicleTrackPage(page, param);
    }

    @Override
    public List<Map<String, Object>> getVehicleRealTrack(VehicleTrail param) {
        return this.baseMapper.getVehicleRealTrack(param);
    }

    @Override
    public List<Map<String, Object>> getVehicleRealTrackPage(Page<Map<String, Object>> page, VehicleTrail param) {
        return this.baseMapper.getVehicleRealTrackPage(page, param);
    }

    @Override
    public void insertTrail(VehicleTrail vehicleTrail) {
        this.baseMapper.insertTrail(vehicleTrail);
    }

    @Override
    public String getLastAccGpsTime(VehicleTrail vehicleTrail) {
        Date gps_time = this.baseMapper.getLastAccGpsTime(vehicleTrail);
        if (gps_time == null) gps_time = DateUtil.getToDayOrigin();
        return DateUtil.formatDate(gps_time, BizConstant.Common.DATE_FORMAT_SECOND.key());
    }
}
